package com.zhixinhuixue.zsyte.xxx.ui.viewmodel

import androidx.lifecycle.MutableLiveData
import com.zhixinhuixue.zsyte.xxx.app.api.NetUrl
import com.zhixinhuixue.zsyte.xxx.data.repository.UserRepository
import com.zhixinhuixue.zsyte.xxx.data.response.MaterialShelvesEntity
import com.zhixinhuixue.zsyte.xxx.data.response.StoresRequisitionSheet
import com.zhixinhuixue.zsyte.xxx.data.response.StoresRequisitionSheetItem
import com.zhixinhuixue.zsyte.xxx.data.response.UserInfo
import me.hgj.mvvmhelper.base.BaseViewModel
import me.hgj.mvvmhelper.core.databinding.BooleanObservableField
import me.hgj.mvvmhelper.core.databinding.StringObservableField
import me.hgj.mvvmhelper.ext.rxHttpRequest
import me.hgj.mvvmhelper.net.LoadingType

/**
 * 作者　: hegaojian
 * 时间　: 2020/11/3
 * 描述　:
 */
class JWWLCXViewModel : BaseViewModel() {

    //账户名
    val userName = StringObservableField()

    //密码
    val password = StringObservableField()

    //是否显示明文密码（登录注册界面）
    var isShowPwd = BooleanObservableField()

    //登录请求信息
    val loginData = MutableLiveData<UserInfo>()


    //登录请求信息
    val itemData = MutableLiveData<List<MaterialShelvesEntity>>()



    /**
     * 根据架位号查询架位所有物料
     * @param StorageRacks_Code String 架位号
     */
    fun getMaterialShelvesById(StorageRacks_Code :String) {
        rxHttpRequest {
            onRequest = {
                itemData.value = UserRepository.getMaterialShelves(StorageRacks_Code).await()
            }
            loadingType = LoadingType.LOADING_DIALOG //选传
            loadingMessage = "正在加载数据....." // 选传
            requestCode = NetUrl.GET_MATERIALSHELVES // 如果要判断接口错误业务 - 必传
        }

    }



}